/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "role_resource")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RoleResource.findAll", query = "SELECT r FROM RoleResource r"),
    @NamedQuery(name = "RoleResource.findByIdroleResource", query = "SELECT r FROM RoleResource r WHERE r.idroleResource = :idroleResource"),
    @NamedQuery(name = "RoleResource.findByViewpermission", query = "SELECT r FROM RoleResource r WHERE r.viewpermission = :viewpermission"),
    @NamedQuery(name = "RoleResource.findByCreatepermission", query = "SELECT r FROM RoleResource r WHERE r.createpermission = :createpermission"),
    @NamedQuery(name = "RoleResource.findByUpdatepermission", query = "SELECT r FROM RoleResource r WHERE r.updatepermission = :updatepermission"),
    @NamedQuery(name = "RoleResource.findByDeletepermission", query = "SELECT r FROM RoleResource r WHERE r.deletepermission = :deletepermission")})
public class RoleResource implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idrole_resource")
    private Integer idroleResource;
    @Basic(optional = false)
    @NotNull
    @Column(name = "viewpermission")
    private boolean viewpermission;
    @Basic(optional = false)
    @NotNull
    @Column(name = "createpermission")
    private boolean createpermission;
    @Basic(optional = false)
    @NotNull
    @Column(name = "updatepermission")
    private boolean updatepermission;
    @Basic(optional = false)
    @NotNull
    @Column(name = "deletepermission")
    private boolean deletepermission;
    @JoinColumn(name = "idresource", referencedColumnName = "idresource")
    @ManyToOne(optional = false)
    private Resource idresource;
    @JoinColumn(name = "idrole", referencedColumnName = "idrole")
    @ManyToOne(optional = false)
    private Role idrole;

    public RoleResource() {
    }

    public RoleResource(Integer idroleResource) {
        this.idroleResource = idroleResource;
    }

    public RoleResource(Integer idroleResource, boolean viewpermission, boolean createpermission, boolean updatepermission, boolean deletepermission) {
        this.idroleResource = idroleResource;
        this.viewpermission = viewpermission;
        this.createpermission = createpermission;
        this.updatepermission = updatepermission;
        this.deletepermission = deletepermission;
    }

    public Integer getIdroleResource() {
        return idroleResource;
    }

    public void setIdroleResource(Integer idroleResource) {
        this.idroleResource = idroleResource;
    }

    public boolean getViewpermission() {
        return viewpermission;
    }

    public void setViewpermission(boolean viewpermission) {
        this.viewpermission = viewpermission;
    }

    public boolean getCreatepermission() {
        return createpermission;
    }

    public void setCreatepermission(boolean createpermission) {
        this.createpermission = createpermission;
    }

    public boolean getUpdatepermission() {
        return updatepermission;
    }

    public void setUpdatepermission(boolean updatepermission) {
        this.updatepermission = updatepermission;
    }

    public boolean getDeletepermission() {
        return deletepermission;
    }

    public void setDeletepermission(boolean deletepermission) {
        this.deletepermission = deletepermission;
    }

    public Resource getIdresource() {
        return idresource;
    }

    public void setIdresource(Resource idresource) {
        this.idresource = idresource;
    }

    public Role getIdrole() {
        return idrole;
    }

    public void setIdrole(Role idrole) {
        this.idrole = idrole;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idroleResource != null ? idroleResource.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RoleResource)) {
            return false;
        }
        RoleResource other = (RoleResource) object;
        if ((this.idroleResource == null && other.idroleResource != null) || (this.idroleResource != null && !this.idroleResource.equals(other.idroleResource))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.RoleResource[ idroleResource=" + idroleResource + " ]";
    }
    
}
